//
//  NSString.h
//  Meng800
//
//  Created by 姚宗超 on 14/7/19.
//  Copyright (c) 2014年 点财网. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (Common)

// 字符串判空
+ (BOOL)stringIsEmpty:(NSString *)aString;
+ (BOOL)stringIsEmpty:(NSString *)aString shouldCleanWhiteSpace:(BOOL)cleanWhiteSpace;

- (NSNumber*)stringToNumber;

- (NSString*)lastLetterByLowercase;

+ (NSString*)firstLetterOfStringByLowercase:(NSString *)aString;

- (NSString*)md5;

+ (NSAttributedString *)bubbleAttributtedStringWithText:(NSString *)text;

+ (void)setDataDetectorsAttributedAttributedString:(NSMutableAttributedString *)attributedString
                                            atText:(NSString *)text
                             withRegularExpression:(NSRegularExpression *)expression
                                        attributes:(NSDictionary *)attributesDict;

#pragma mark - REGEX
/**
 Takes in a regular expression string to determine whether self evaluates with it or not.
 @param regexString - NSString of the regular expression
 @returns BOOL
 */
- (BOOL)matchesRegex:(NSString *)regexString;

#pragma mark - Validation
- (BOOL)isChineseCharacter; // 是否为中文
- (BOOL)isEnglishCharacter; // 是否为英文

- (BOOL)isNormal;		// thanks to @uxyheaven
- (BOOL)isTelephone;
- (BOOL)isUserName;
- (BOOL)isChineseUserName;
- (BOOL)isPassword;
- (BOOL)isEmail;
- (BOOL)isUrl;
- (BOOL)isIPAddress;

#if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
- (CGSize)sizeWithFont:(UIFont *)font byWidth:(CGFloat)width;
- (CGSize)sizeWithFont:(UIFont *)font byHeight:(CGFloat)height;
#endif	// #if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)

@end
